package com.autumn.zero.authorization.repositorys.roles;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import com.autumn.domain.repositories.IDefaultEntityRepository;
import com.autumn.zero.authorization.entitys.roles.RolePermission;

/**
 * 角色授权仓储
 * 
 * @author 杨昌国 2018-11-29 21:07:33
 */
@Repository
public interface IRolePermissionRepository extends IDefaultEntityRepository<RolePermission> {

	/**
	 * 根据角色与资源类型删除权限
	 * 
	 * @param roleId
	 *            角色id
	 * @param resourcesType
	 *            资源类型
	 * @return
	 */
	@Delete("DELETE p FROM sys_role_permission AS p INNER JOIN sys_res_module as m on p.resources_id = m.id WHERE p.role_id = #{roleId} and m.resources_type = #{resourcesType}")
	int deleteByRoleAndResourcesType(@Param("roleId") long roleId, @Param("resourcesType") int resourcesType);

}
